package com.example.demo3.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.example.demo3.util.CryptService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author allnas
 */
@MapperScan("com.example.demo3.dao")
@Configuration
public class MybatisPlusConfig {
    @Bean
    public CryptService cryptService() {
        return new CryptService();
    }

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        // 初始化 MybatisPlusInterceptor 核心插件
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 添加自动分页插件 PaginationInnerInterceptor
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        // 返回
        return interceptor;
    }
}
